Skip to content

[EP Plugin Adapter] support LoggingManager::HasDefaultLogger()#27587

Merged
fs-eire merged 1 commit intomainfrom
fs-eire/logging-manager
Mar 11, 2026
Merged

[EP Plugin Adapter] support LoggingManager::HasDefaultLogger()#27587
fs-eire merged 1 commit intomainfrom
fs-eire/logging-manager

Conversation

@fs-eire
Copy link
Copy Markdown
Contributor

@fs-eire fs-eire commented Mar 8, 2026

Description

Add support for LoggingManager::HasDefaultLogger().

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the EP plugin adapter logging surface to expose LoggingManager::HasDefaultLogger() (mirroring the main ORT logging API shape) so plugin EP code can query whether a default logger is available.

Changes:

  • Introduce onnxruntime::ep::adapter::LoggingManager with HasDefaultLogger() and move default-logger management off Logger.
  • Update the adapter’s LOGS_DEFAULT_CATEGORY macro to use LoggingManager::DefaultLogger().
  • Expose LoggingManager via EP-specific using declarations in include/onnxruntime/ep/adapters.h.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
include/onnxruntime/ep/adapters.h Exposes LoggingManager in the EP plugin adapter’s logging namespace aliases.
include/onnxruntime/ep/adapter/logging.h Adds adapter LoggingManager (with HasDefaultLogger) and routes default logging macros through it.
Comments suppressed due to low confidence (1)

include/onnxruntime/ep/adapter/logging.h:47

  • LoggingManager::DefaultLogger() dereferences instance_ without checking it is initialized, which is undefined behavior if logging is used before CreateDefaultLogger() is called. Also, CreateDefaultLogger() overwrites instance_ without deleting/guarding against an existing logger, which can leak if called more than once. Consider matching ::onnxruntime::logging::LoggingManager behavior: throw (or otherwise fail fast) if instance_ is null in DefaultLogger(), and either throw if instance_ is already set or delete/require DestroyDefaultLogger() before re-creating.
  static bool HasDefaultLogger() { return nullptr != instance_; }
  static const Logger& DefaultLogger() { return *instance_; }
  static void CreateDefaultLogger(const OrtLogger* logger) {
    instance_ = new Logger(logger);
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fs-eire fs-eire merged commit c07ece3 into main Mar 11, 2026
101 of 103 checks passed
@fs-eire fs-eire deleted the fs-eire/logging-manager branch March 11, 2026 16:41
fs-eire added a commit that referenced this pull request Mar 24, 2026
### Description

This PR makes it possible to build WebGPU EP as an EP API based plugin
EP.

#### Requirements

The goal of this PR is to support both building WebGPU EP as a bundled
EP and an EP API based plugin EP. This approach allows:
- enabling WebGPU EP as a standalone plugin EP package for WCR usage
- graceful transition for WebGPU EP as an native EP for language
binding, from the bundled EP to an EP API based plugin EP
- keep the existing usage (static library) working (majorly for web)




#### Design & Implementation

Instead of **changing** WebGPU EP from a bundled EP to an EP API based
plugin EP in one shot, this PR **extend** WebGPU EP to support building
as plugin EP.

- add a new folder `include/onnxruntime/ep` with a bunches of header
files. Those files are not WebGPU specific. They are used for:
  - include common defines/functions/macros for plugin EP to use
- include a few "adapter" classes that takes C-API objects to simulate
ORT internal classes behaviors
- include a few "override" classes that simulate ORT internal classes,
but using implementations that only depend on C-API
  - include a special base class `onnxruntime::ep::Ep` to inherit from
  
These header files allow a compile time "switch" to the different set of
types to minimize changes to existing code. Specifically, `pch.h` is
required to be included as PCH to make sure the "override" to take place
correctly.

- add a new folder `onnxruntime/core/providers/webgpu/ep` for EP API
implementation, specifically:
  - `api.cc`: implements `CreateEpFactories` and `ReleaseEpFactory`
  - `ep.cc` `ep.h`: implement class `onnxruntime::webgpu::ep::Ep`
- `factory.cc` `factory.h`: implement class
`onnxruntime::webgpu::ep::Factory`

#### Dependencies and Prerequisites

(unmerged changes are included as a part of current PR)

- #26855
- #26803
- #26859
- #26879
- #26919
- #27569
- #27587

#### Missing Parts

- Allow setting Global/Default EP options

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants